import Vue from 'vue'
import Vuex from 'vuex'
import persistence from 'vuex-uniapp-persistence'
import system from './modules/system.js'
import user from './modules/user.js'
// 引入地址模块
import address from './modules/address.js'

// 注册插件
Vue.use(Vuex)
// 构建一个默认的store仓库
// state  getters mutations actions modules plugins
// vuex持久化的插件
const store = new Vuex.Store({
  state: {
    count: 1,
  },
  mutations: {
    addCount(state) {
      state.count++
    },
  },
  getters: {},
  modules: {
    system, // 当前模块名是system
    user,
    address, // 注册模块
  },
  plugins: [persistence()], // vuex里面也可以注册插件
})

export default store
